package dailearn.feign.controller;

import dailearn.feign.entity.User;
import dailearn.feign.producer.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author daify
 * @date 2019-07-13
 */
@RestController
@Slf4j
public class UserController {

    @Autowired
    private UserService userService;


    @RequestMapping(value = "user",method = RequestMethod.GET)
    public String getUserInfo() {
        User user = new User("test",10);
        log.info("userInfo: name-{},age-{}",user.getName(),user.getAge());
        return userService.getUserInfo(user);
    }


    @RequestMapping(value = "getNumber",method = RequestMethod.GET)
    public String getNumber() {
        return userService.getNumber(10);
    }


    @RequestMapping(value = "getStr",method = RequestMethod.GET)
    public String getStr() {
        return userService.getStr("test");
    }

    @RequestMapping(value = "getStrV2",method = RequestMethod.GET)
    public String getStrV2() {
        return userService.getStrV2("testV2");
    }

    @RequestMapping(value = "getNone",method = RequestMethod.GET)
    public String getNone() {
        return userService.getNone();
    }

    @RequestMapping(value = "getId",method = RequestMethod.GET)
    public String getId() {
        return userService.getId(5L);
    }

    @RequestMapping(value = "getIdV2",method = RequestMethod.GET)
    public String getIdV2() {
        return userService.getIdV2(5L);
    }
}